/*
 * Copyright 2009 Max Kugland
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.splink.deepsplink.page.params {

	/**
	 * A <code>PageParameter</code> is the object representation of the url part after the "?" 
	 * 
	 * Each <code>Page</code> which is open or to be opened is provided with the current
	 * page parameters. 
	 * 
	 * In this url the id of the page is "page13" and the parameters of "page13" are
	 * "id" (value:"someId") and "productId" (value:"someProductId")
	 *  
	 * <code> 
	 * http://www.something.com/index.html#/page13/?id=someId&productId=someProductId
	 * </code>
	 * 
	 * <code>PageParameterUtil</code> provides methods to extract page parameters
	 * and pageId from an url
	 * 
	 * @see org.splink.deepsplink.page.params.PageParameterUtil
	 * @author Max Kugland
	 */
	final public class PageParameter {
		/**
		 * The key of the key-value pair
		 */
		public var key : String;
		/**
		 * The value of the key-value pair
		 */
		public var value : String;
		
		/**
		 * @param key the key
		 * @param value the value
		 */
		public function PageParameter(key : String, value : String) {
			this.key = key;			this.value = value;
		}

		/**
		 * @return a <code>String</code> representation of the parameter
		 */
		public function toString() : String {
			return key + " : " + value;
		}
		
		/**
		 * @return whether this and the given <code>PageParameter</code> are equal
		 */
		public function equals(p : PageParameter) : Boolean {
			if(p == null) return false;
			if(key != p.key) return false;
			if(value != p.value) return false;
			return true;
		}
	}
}
